//--------------------------------------------------------------------------------
// This file is a portion of the D2D1Renderer.  It is distributed
// under the MIT License, available in the root of this distribution and 
// at the following URL:
//
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) Mirco Timmermann
//
//--------------------------------------------------------------------------------
#include "Text.h"

namespace D2 {

Text::Text() {
	_text = "";
	_font = "";
	_maxWidth = 100;
	_textHeight = 20;

	//std::string _color;
	float _r = 0.0f;
	float _g = 0.0f;
	float _b = 0.0f;
}

Text::Text(int x, int y) : DisplayObject(x, y, 0, 0) {
	//Direct2DContext::Dimension dim = ctx->measureText(inputChannel->_name);
}

Text::Text(int x, int y, int width, int height) : DisplayObject(x, y, width, height) {
	
}

Text::~Text(void) {

}

/////////////////////////////DATA////////////////////////////
bool Text::Draw(Direct2DContext* ctx, D2D1::Matrix3x2F* mtx) {
	//ctx->_disableCamera = true;

	Direct2DContext::Dimension dim = ctx->measureText(_text);
	_width = dim.width;
	_height = dim.height;

	//var lines = String(this.text).split(/(?:\r\n|\r|\n)/);
	ctx->SetStrokeStyle(_r, _g, _b);
	ctx->fillText(_text, 0, 0, _textHeight);

	//ctx->_disableCamera = false;

	return true;
}

void Text::SetText(std::string text) {
	_text = text;
}

std::string Text::GetText() {
	return _text;
}

}